#include "task/retinaface.h"


int main(int argc, char **argv)
{
    RetinafaceCustom retinaface;
    // model file path
    const char *model_file = argv[1];
    // input img path
    const char *img_file = argv[2];
    // load image
    cv::Mat img = cv::imread(img_file);
    cv::Mat origin_img = img;
    printf("The img size is %d , %d\n", img.cols, img.rows);
    // load model file
    retinaface.LoadModel(model_file);

    retinaface_result result;
    retinaface.Run(img, &result);

    // printf("result count : %d", result.count);
    for (int i = 0; i < result.count; ++i) {
        int x1 = result.object[i].box.left;
        int y1 = result.object[i].box.top;
        int x2 = result.object[i].box.right;
        int y2 = result.object[i].box.bottom;
        cv::Rect bbox(x1, y1, x2-x1, y2-y1);
        cv::Mat crop_img = origin_img(bbox);
        cv::Mat align_img;
        retinaface.FaceAlignment(crop_img, align_img, &result.object[i]);
        cv::imwrite("crop_img.jpg", crop_img);
        cv::imwrite("align_img.jpg", align_img);
        
        cv::rectangle(origin_img, cv::Point(x1, y1), cv::Point(x2, y2), cv::Scalar(255, 0, 255), 3);
        for(int j=0; j< 5; j++)
        {
            cv::circle(origin_img, cv::Point(result.object[i].ponit[j].x, result.object[i].ponit[j].y), 4, cv::Scalar(0, 0, 255), 2, cv::LINE_AA, 0);
        }
    }
    cv::imwrite("res.jpg", origin_img);
    return 0;
}
